package com.zhiqianbao.view;

import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.webkit.WebView;

public class WebView4Scroll extends WebView {

    private SwipeRefreshLayout swipeRefreshLayout;

    public WebView4Scroll(Context context) {
        super(context);
    }
    public WebView4Scroll(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setSwipeRefreshLayout( SwipeRefreshLayout swipeRefreshLayout){
        this.swipeRefreshLayout = swipeRefreshLayout;
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (this.getScrollY() == 0){
            if(swipeRefreshLayout!=null) {
                swipeRefreshLayout.setEnabled(true);
            }
        }else {
            if(swipeRefreshLayout!=null) {
                swipeRefreshLayout.setEnabled(false);
            }
        }
    }
}
